package com.example.wtt.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.wtt.controller.dto.CollectDTO;
import com.example.wtt.controller.dto.DynamicDTO;
import com.example.wtt.controller.dto.UpvoteDTO;
import com.example.wtt.entity.Dynamic;
import com.example.wtt.mapper.DynamicMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DynamicService extends ServiceImpl<DynamicMapper, Dynamic> {
    @Autowired
    private DynamicMapper dynamicMapper;

    public List<DynamicDTO> allDynamics(Integer pageNum, Integer pageSize) {
        pageNum = pageNum * pageSize;
        return dynamicMapper.allDynamics(pageNum, pageSize);
    }

    public Object publicDynamic(Object obj) {
        return dynamicMapper.publishDynamic(obj);
    }


    public Integer upvoteSum(Integer dynamicId) {
        return dynamicMapper.upvoteSum(dynamicId);
    }

    public Integer upvoteSub(Integer dynamicId) {
        return dynamicMapper.upvoteSub(dynamicId);
    }

    public Integer collectSum(CollectDTO collectDTO) {
        return dynamicMapper.collectSum(collectDTO);
    }

    public Integer collectSub(CollectDTO collectDTO) {
        return dynamicMapper.collectSub(collectDTO);
    }

    public Integer queryCollect(CollectDTO collectDTO){
        return dynamicMapper.queryCollect(collectDTO);
    }

    public List<DynamicDTO> queryDynamic(String describe) {
        return dynamicMapper.queryDynamic(describe);
    }
}
